//
//  OrderSubCell.m
//  NewPro
//
//  Created by RYX on 2018/10/11.
//  Copyright © 2018年 何荧红. All rights reserved.
//

#import "OrderSubCell.h"
#import "OrderCenterModel.h"

@implementation OrderSubCell

+ (instancetype)tempWithTableView:(UITableView *)tableView{
    
    NSString *identity = @"CELL";
    NSInteger index = 0;
    
    OrderSubCell *cell = [tableView dequeueReusableCellWithIdentifier:identity];
    if (!cell) {
        
        ClassName
        cell = [[[NSBundle mainBundle] loadNibNamed:className owner:self options:nil] objectAtIndex:index];
    }
    return cell;
}

+ (CGFloat)getHeight{
    
    UITableViewCell *cell = [self cell];
    return cell.frame.size.height;
}

+ (instancetype)cell{
    
    ClassName
    
    return [[[NSBundle mainBundle] loadNibNamed:className owner:self options:nil] objectAtIndex:0];
}

- (void)setAlphaWithType:(NSInteger)type{
    
    self.cancleBtn.alpha = 0;
    self.payBtn.alpha = 0;
    self.receiveGoodsBtn.alpha = 0;
    self.lookWuliuBtn.alpha = 0;
    self.lookOrderDetailBtn.alpha = 0;
    
    if (type == 0) {
        
        self.cancleBtn.alpha = 1;
        self.payBtn.alpha = 1;
        self.statueLa.text = @"等待买家付款";
        
    }else if (type == 1){
        
        self.statueLa.text = @"等待商家发货";
    }
    else if (type == 2){
        
        self.receiveGoodsBtn.alpha = 1;
        self.lookWuliuBtn.alpha = 1;
        self.statueLa.text = @"商家已发货";
        
    }else if (type == 3){
        
        self.lookOrderDetailBtn.alpha = 1;
        self.statueLa.text = @"卖家已签收";
        
    }
}
- (IBAction)onCancleBtn:(UIButton *)sender {
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(onCancleBtnWithIndexPath:)]) {
        
        [self.delegate onCancleBtnWithIndexPath:self.indexPath];
    }
}

- (IBAction)onPayBtn:(UIButton *)sender {
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(onPayBtnWithIndexPath:)]) {
        
        [self.delegate onPayBtnWithIndexPath:self.indexPath];
    }
}

- (IBAction)onReceiveGoodsBtn:(id)sender {
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(onReceiveGoodsBtnWithIndexPath:)]) {
        
        [self.delegate onReceiveGoodsBtnWithIndexPath:self.indexPath];
    }
}

- (IBAction)onLookWuLiuBtn:(id)sender {
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(onLookWuLiuBtnWithIndexPath:)]) {
        
        [self.delegate onLookWuLiuBtnWithIndexPath:self.indexPath];
    }
}

- (IBAction)onLookOrderDeTailBtn:(id)sender {
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(onLookOrderDetailBtnWithIndexPath:)]) {
        
        [self.delegate onLookOrderDetailBtnWithIndexPath:self.indexPath];
    }
}


-(void)setModel:(OrderCenterModel *)model{
    
    [self.iconIm sd_setImageWithURL:[NSURL URLWithString:model.imgpath] placeholderImage:nil];
    
    self.titleLa.text = [NSString stringWithFormat:@"%@",model.name];
    self.priceLa.text = [NSString stringWithFormat:@"¥ %@",model.price];
    self.numLa.text = [NSString stringWithFormat:@"X%@",model.num];
    self.desLa.text = [NSString stringWithFormat:@"共计%@件商品：¥ %@",model.num,model.totalAmount];
    self.timeLa.text = [StrTool changeWithTime:model.gmtCreate];
    if (self.type == 3) {
     
        if (model.logicUntilDay.length <= 0) {
            
            self.lookOrderDetailBtn.alpha = 0;
        }else{
            
            self.lookOrderDetailBtn.alpha = 1;
        }
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
